// pages/filmTimes/filmTimes.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    times:[],
    username:''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var page = this;
    page.setData({username:options.username});
    wx.request({
      url: 'http://127.0.0.1:8080/getAllTimesByFilmName_wx',
      data:{
       'filmName': options.filmName,
       'username':options.username
    },
      header:{
        'Content-Type':'json'
      },
      success:function(res){
        console.log(res);
        var times = new Array();
        var subjects = res.data.data;
        var len =null;
        if(subjects==null){
            len=0
            wx.showToast({
              title: '暂无排片',
              icon: 'none',
              duration: 1500
          })  
        }else{
          len =subjects.length ;
        }
       
        for(var i=0;i<len;i++){
           var subject = subjects[i];
           var time = new Object();
           time.id = subject.Film_times_id;
           time.date = subject.Film_date;
           time.time = subject.Film_time;
           time.version = subject.Language_version;
           time.cinema = subject.Cinema_name;
           time.hall = subject.Hall_name;
           time.price = subject.Film_price;
           
           times.push(time);

        }
        console.log(times);
        page.setData({times:times});
        wx.setNavigationBarTitle({
          title: options.filmName+'场次表'
        })
      }
    })
  },
  btnBuy:function(e){
    var timeId = e.currentTarget.dataset.text+""
    var username=this.data.username
    console.log(username+'|'+timeId);
   wx.navigateTo({
    url: '../seatSelect/seatSelect?timeId='+timeId+'&username='+username
  }) 
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})